/*
 ============================================================================
 Name		: ResponseDispatcher.cpp
 Author	  : 
 Version	 : 1.0
 Copyright   :
 Description : CResponseDispatcher implementation
 ============================================================================
 */

#include "ResponseDetail.h"
#include "ResponseDefinses.h"
#include "ProjectsDefines.h"
#include "ResponseMagazineItemData.h"

CResponseDetail::CResponseDetail( )
{
    // No implementation required
}

CResponseDetail::~CResponseDetail( )
{
    SAFE_DELETE( _data );
}

CResponseDetail* CResponseDetail::NewLC( )
{
    CResponseDetail* self = new ( ELeave ) CResponseDetail( );
    CleanupStack::PushL( self );
    self->ConstructL( );
    return self;
}

CResponseDetail* CResponseDetail::NewL( )
{
    CResponseDetail* self = CResponseDetail::NewLC( );
    CleanupStack::Pop( ); // self;
    return self;
}

void CResponseDetail::ConstructL( )
{
    
}

void CResponseDetail::LoadValidResponseFromXmlNode( CElement* elementResponse )
{
    _ASSERT_LOG( elementResponse != NULL );

    if( !elementResponse )
    {
        return;
    }

    CElement* elemetnResult = elementResponse->GetElement( kResponseResultNode );
    _ASSERT_LOG( elemetnResult );

    if( !elemetnResult )
    {
        return;
    }
    //_LIT( kResponseChildCateNode, "child_cate");
    //_LIT( kResponseCC_IDNode, "cc_id");
    _LIT( kResponseInfoNode , "info");
    //_LIT( kResponseM_IDNode, "m_id");
    int count = elemetnResult->ElementCount( );
    for( int index = 0; index < count; index++ )
    {
        CElement* element = elemetnResult->GetElement( index );
        //_LIT( kResponseDipathcerItemNode, "items" );
        if( element && element->GetName( ) == kResponseInfoNode )
        {
            _data = ResponseMagazineItemDataParser::Parse( element );
        }
    }
}
